#region Summary

// 
// Owner : JackieHan 
// 
// Solution : ResearchTest 
// 
// Project : TestSerializer
// 
// File : Group.cs
// 
// CopyRight : Copyright © 2010-2011 Skomart Corporation, All Rights Reserved 
// 
// Summary : Serializer With XmlTypeMapping
// 
// History : 
//			2011-04-15 11:44:53	    Create 
// 

#endregion

#region Using

using System;
using System.Xml.Serialization;

#endregion

namespace TestSerializer
{
    /// <summary> 
    /// Serializer With XmlTypeMapping
    /// </summary>
    public class Group
    {
        public static Group GetDefalutInstance()
        {
            var hexByte = new Byte[2] { Convert.ToByte(100), Convert.ToByte(50) };
            var thisCar = (Car)MyCar("1234566");
            var myGroup = new Group
                              {
                                  GroupName = ".NET",
                                  GroupNumber = hexByte,
                                  Today = new DateTime(2002, 5, 2),
                                  PostitiveInt = "10000",
                                  IgnoreThis = true,
                                  GroupType = GroupType.B,
                                  MyVehicle = thisCar
                              };
            return myGroup;

        }

        [SoapAttribute(Namespace = "http://www.cpandl.com")]
        public string GroupName { get; set; }

        [SoapAttribute(DataType = "base64Binary")]
        public byte[] GroupNumber { get; set; }

        [SoapAttribute(DataType = "date", AttributeName = "CreationDate")]
        public DateTime Today { get; set; }

        [SoapElement(DataType = "nonNegativeInteger", ElementName = "PostInt")]
        public string PostitiveInt { get; set; }

        [SoapIgnore]
        public bool IgnoreThis { get; set; }

        public GroupType GroupType { get; set; }

        public Vehicle MyVehicle { get; set; }

        [SoapInclude(typeof(Car))]
        public static Vehicle MyCar(string licNumber)
        {
            Vehicle v;
            if (licNumber == "")
            {
                v = new Car();
                v.LicenseNumber = "!!!!!!";
            }
            else
            {
                v = new Car();
                v.LicenseNumber = licNumber;
            }
            return v;
        }
    }

    [SoapInclude(typeof(Car))]
    public abstract class Vehicle
    {
        public string LicenseNumber { get; set; }
        public DateTime MakeDate { get; set; }
    }

    public class Car : Vehicle
    {

    }

    public enum GroupType
    {
        [SoapEnum("Small")]
        A,
        [SoapEnum("Large")]
        B
    }
}